package com.x.mvp.widget.ruler;

import android.graphics.Canvas;
import android.graphics.Paint;
import android.graphics.Path;

/**
 * Created by H on 18/3/5.
 */

public class TrigleRander extends Rander {
    Paint forePan;
    Path path;
    private int dot = 20;
    public TrigleRander(int foregoundColor, int backgoundColor, int split, int totalLength, int offset) {
        super(foregoundColor, backgoundColor, split, totalLength, offset);
    }

    @Override
    void init() {
        super.init();
        forePan = new Paint();
        forePan.setColor(foregoundColor);
        forePan.setStrokeWidth(2f);
        forePan.setAntiAlias(true);
        forePan.setTextSize(25);
        forePan.setStyle(Paint.Style.FILL);

    }

    public void setDot(int dot) {
        this.dot = dot;
        path = new Path();
        path.moveTo(dot - 20, 0);// 此点为多边形的起点
        path.lineTo(dot + 20, 0);
        path.lineTo(dot, 60);
        path.close(); // 使这些点构成封闭的多边形
    }

    @Override
    public void onDraw(Canvas canvas) {
        int w = canvas.getWidth();
        int h = canvas.getHeight();
        int[] fir = getFirstScale(w);
        canvas.drawPath(path, forePan);
    }
}
